package pl.edu.agh.gp.stock;

import pl.edu.agh.model.core.Price;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.LinkedList;
import java.util.List;

public class StockDataProvider {
    private SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");

    public List<Price> getUpSlopePrices() {
        List<Price> prices = new LinkedList<Price>();

        prices.add(getPrice("01-01-2000", 41.23, 44.25, 40.23, 42.56, 742853));
        prices.add(getPrice("02-01-2000", 48.23, 59.25, 45.23, 53.56, 647434));
        prices.add(getPrice("03-01-2000", 61.23, 69.25, 55.23, 64.56, 764547));
        prices.add(getPrice("04-01-2000", 77.23, 82.25, 70.23, 75.56, 453455));
        prices.add(getPrice("05-01-2000", 80.23, 81.25, 79.23, 80.56, 45455));
        prices.add(getPrice("06-01-2000", 89.23, 99.25, 80.23, 95.56, 765333));
        prices.add(getPrice("07-01-2000", 112.23, 115.25, 101.23, 110.56, 765433));

        return prices;
    }

    public List<Price> getVariedSlopePrices() {
        List<Price> prices = new LinkedList<Price>();

        prices.add(getPrice("01-01-2000", 2.1, 3.55, 1.20,1.56, 56456));
        prices.add(getPrice("02-01-2000", 44.23, 49.3, 38.56, 43.66, 654645));
        prices.add(getPrice("03-01-2000", 307.56, 313.5, 280.78, 300.86, 546453));
        prices.add(getPrice("04-01-2000", 5.23, 9.34, 2.54, 5.86, 434344));
        prices.add(getPrice("05-01-2000", 6.55, 6.99, 6.34, 6.86, 542423));
        prices.add(getPrice("06-01-2000", 221.12, 223.5, 218.4, 220.86, 676765));
        prices.add(getPrice("07-01-2000", 49.0, 53.7, 44.34, 47.86, 4323));
        prices.add(getPrice("06-01-2000", 87.34, 95.76, 82.56, 90.86, 87665));
        prices.add(getPrice("07-01-2000", 109.35, 115.64, 105.34, 111.86, 24234));

        return prices;
    }

    public List<Price> getDownSlopePrices() {
        List<Price> prices = new LinkedList<Price>();

        prices.add(getPrice("01-01-2000", 112.23, 115.25, 101.23, 110.56, 86545));
        prices.add(getPrice("02-01-2000", 89.23, 99.25, 80.23, 95.56, 2435));
        prices.add(getPrice("03-01-2000", 80.23, 81.25, 79.23, 80.56, 64534));
        prices.add(getPrice("04-01-2000", 77.23, 82.25, 70.23, 75.56, 56643));
        prices.add(getPrice("05-01-2000", 61.23, 69.25, 55.23, 64.56, 56543));
        prices.add(getPrice("06-01-2000", 48.23, 59.25, 45.23, 53.56, 85675));
        prices.add(getPrice("07-01-2000", 41.23, 44.25, 40.23, 42.56, 22444));

        return prices;
    }

    private Price getPrice(String dateStr, double open, double high, double low, double close, long volume)  {
        try {
            return new Price("mockStock",sdf.parse(dateStr), open, high, low, close, 0.0, volume);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
